<html>
<head><meta charset="utf-8"><title>Building cranelift with stage1 compiler · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html">Building cranelift with stage1 compiler</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="246638592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246638592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246638592">(Jul 20 2021 at 19:38)</a>:</h4>
<p>I've enabled cranelift in my <code>config.toml</code>, and I'm trying to perform a build with <code>./x.py build --stage 1 library/std</code>. When I run a build, the <code>rustc_codegen_cranelift</code> crate compies, but fails to link with the following error:</p>



<a name="246638610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246638610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246638610">(Jul 20 2021 at 19:38)</a>:</h4>
<p><code>  = note: /usr/sbin/ld: cannot find -lLLVM-12-rust-1.55.0-nightly</code></p>



<a name="246638640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246638640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246638640">(Jul 20 2021 at 19:38)</a>:</h4>
<p>I'm not sure why cranelift would be trying to link against llvm</p>



<a name="246638932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246638932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246638932">(Jul 20 2021 at 19:41)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="133247">@bjorn3</span>  - is there anything else that I need to do to build a stage1 cranelift in-tree?</p>



<a name="246641143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246641143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246641143">(Jul 20 2021 at 19:57)</a>:</h4>
<p>Ok, it looks like the problem only occurs if I specify both "llvm" and "cranelift" in <code>codegen-backends</code></p>



<a name="246641283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246641283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246641283">(Jul 20 2021 at 19:58)</a>:</h4>
<p>I believe I fixed that error on my rustup component PR.</p>



<a name="246641444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246641444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246641444">(Jul 20 2021 at 19:59)</a>:</h4>
<p>What happens is that cg_llvm is linked into rustc_driver. This means that the linker must be able to find LLVM whenever any crate (like cg_clif) links against rustc_driver.</p>



<a name="246641688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246641688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246641688">(Jul 20 2021 at 20:01)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/81746/files#diff-6e3c7e8b58a9a198adc885bced48fff2c5fd9a1ee126ccce52166476a536807fR1275">https://github.com/rust-lang/rust/pull/81746/files#diff-6e3c7e8b58a9a198adc885bced48fff2c5fd9a1ee126ccce52166476a536807fR1275</a></p>



<a name="246641718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20cranelift%20with%20stage1%20compiler/near/246641718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20cranelift.20with.20stage1.20compiler.html#246641718">(Jul 20 2021 at 20:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> ^ this is the fix</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>